package com.fastbee.oss.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fastbee.common.annotation.Log;
import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.common.enums.BusinessType;
import com.fastbee.oss.domain.OssDetail;
import com.fastbee.oss.service.IOssDetailService;
import com.fastbee.common.utils.poi.ExcelUtil;
import com.fastbee.common.core.page.TableDataInfo;

/**
 * 文件记录Controller
 * 
 * @author zhuangpeng.li
 * @date 2023-03-30
 */
@Api(tags = "文件记录")
@RestController
@RequestMapping("/oss/OssDetail")
public class OssDetailController extends BaseController
{
    @Autowired
    private IOssDetailService ossDetailService;

    /**
     * 查询文件记录列表
     */
    @ApiOperation("查询文件记录列表")
    @PreAuthorize("@ss.hasPermi('oss:OssDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(OssDetail ossDetail)
    {
        startPage();
        List<OssDetail> list = ossDetailService.selectOssDetailList(ossDetail);
        return getDataTable(list);
    }

    /**
     * 导出文件记录列表
     */
    @ApiOperation("导出文件记录列表")
    @PreAuthorize("@ss.hasPermi('oss:OssDetail:export')")
    @Log(title = "文件记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OssDetail ossDetail)
    {
        List<OssDetail> list = ossDetailService.selectOssDetailList(ossDetail);
        ExcelUtil<OssDetail> util = new ExcelUtil<OssDetail>(OssDetail.class);
        util.exportExcel(response, list, "文件记录数据");
    }

    /**
     * 获取文件记录详细信息
     */
    @ApiOperation("获取文件记录详细信息")
    @PreAuthorize("@ss.hasPermi('oss:OssDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(ossDetailService.selectOssDetailById(id));
    }

    /**
     * 新增文件记录
     */
    @ApiOperation("新增文件记录")
    @PreAuthorize("@ss.hasPermi('oss:OssDetail:add')")
    @Log(title = "文件记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OssDetail ossDetail)
    {
        return toAjax(ossDetailService.insertOssDetail(ossDetail));
    }

    /**
     * 修改文件记录
     */
    @ApiOperation("修改文件记录")
    @PreAuthorize("@ss.hasPermi('oss:OssDetail:edit')")
    @Log(title = "文件记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OssDetail ossDetail)
    {
        return toAjax(ossDetailService.updateOssDetail(ossDetail));
    }

    /**
     * 删除文件记录
     */
    @ApiOperation("删除文件记录")
    @PreAuthorize("@ss.hasPermi('oss:OssDetail:remove')")
    @Log(title = "文件记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(ossDetailService.deleteOssDetailByIds(ids));
    }
}
